package com.woniu.core.controller;

import com.woniu.aop.OperationLogAnnotation;
import com.woniu.core.entity.CoreRecourse;
import com.woniu.core.service.CoreRecourseService;
import com.woniu.util.utils.HttpResult;
import com.woniu.util.utils.RequestParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/recourse")
@Slf4j
public class CoreRecourseController {

    @Autowired
    private CoreRecourseService coreRecourseService;

    @GetMapping("/pending")
//    @PreAuthorize("hasAuthority('core:finance')")
    @OperationLogAnnotation(operModul = "核心企业-财务部门", operType = "查询", operDesc = "查询所有待追偿项目")
    public HttpResult<?> pendingRecourse(String coreUserAccount) {
        return coreRecourseService.pendingRecourse(coreUserAccount);
    }


    @PostMapping("/check")
//    @PreAuthorize("hasAuthority('core:finance')")
    @OperationLogAnnotation(operModul = "核心企业-财务部门", operType = "查询", operDesc = "查询所有追偿记录")
    public HttpResult<?> checkRecourse(@RequestBody RequestParam<String> requestParam) {
        return coreRecourseService.checkRecourse(requestParam);
    }

    @GetMapping("/doRecourse")
//    @PreAuthorize("hasAuthority('core:finance')")
    @OperationLogAnnotation(operModul = "核心企业-财务部门", operType = "新增，修改", operDesc = "追偿操作")
    public HttpResult<?> doRecourse(Integer recourseId) {
        return coreRecourseService.doRecourse(recourseId);
    }
}
